<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title th:text="${document.id != null ? '编辑文档' : '创建文档'} + ' - 控制面板'">文档管理 - 控制面板</title>
    <link rel="stylesheet" href="/css/style.css">
    <style>
        .form-document {
            margin-top: 20px;
        }
        .form-group {
            margin-bottom: 20px;
        }
        .form-check {
            margin-top: 20px;
        }
        textarea.form-control {
            min-height: 300px;
            resize: vertical;
        }
    </style>
</head>
<body>
    <div class="dashboard-container">
        <div class="sidebar">
            <div class="sidebar-header">
                <h2>控制面板</h2>
            </div>
            <ul class="sidebar-menu">
                <li><a href="/dashboard">主页</a></li>
                <li><a href="/dashboard/profile">个人信息</a></li>
                <li><a href="/dashboard/change-password">修改密码</a></li>
                <li class="active"><a href="/dashboard/documents">文档管理</a></li>
                <li><a href="/" target="_blank">访问首页</a></li>
                <li><a href="/logout">退出登录</a></li>
            </ul>
        </div>
        
        <div class="main-content">
            <div class="dashboard-header">
                <div class="dashboard-title">
                    <h1 th:text="${document.id != null ? '编辑文档' : '创建文档'}">文档表单</h1>
                </div>
                <div>
                    <a href="/dashboard/documents" class="btn btn-secondary">返回文档列表</a>
                </div>
            </div>
            
            <form th:action="${document.id != null ? '/dashboard/documents/edit/' + document.id : '/dashboard/documents/create'}" 
                  method="post" 
                  th:object="${document}" 
                  class="form-document">
                  
                <div class="form-group">
                    <label for="title">标题</label>
                    <input type="text" id="title" name="title" th:field="*{title}" class="form-control" required>
                </div>
                
                <div class="form-group">
                    <label for="content">内容</label>
                    <textarea id="content" name="content" th:field="*{content}" class="form-control" required></textarea>
                </div>
                
                <div class="form-check">
                    <input type="checkbox" id="featured" name="featured" th:field="*{featured}" class="form-check-input">
                    <label for="featured" class="form-check-label">在首页显示</label>
                </div>
                
                <div class="form-group mt-4">
                    <button type="submit" class="btn btn-primary">保存</button>
                    <a href="/dashboard/documents" class="btn btn-secondary">取消</a>
                </div>
            </form>
        </div>
    </div>
    
    <script src="/js/script.js"></script>
</body>
</html> 